home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 4 / QRZ Ham Radio Callsign Database - Volume 4.iso / files / tcpip / amiga / asrc29p.lha / sockcmd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-29  |  1.4 KB  |  78 lines

  1. #include <stdio.h>
  2. #include "global.h"
  3. #include "mbuf.h"
  4. #include "proc.h"
  5. #include "usock.h"
  6. #include "socket.h"
  7. #include "ax25.h"
  8. #include "netrom.h"
  9. #include "tcp.h"
  10. #include "udp.h"
  11. #include "commands.h"
  12. #include "config.h"
  13.  
  14. /* Socket status display command */
  15. int
  16. dosock(argc,argv,p)
  17. int argc;
  18. char *argv[];
  19. void *p;
  20. {
  21.     register struct usock *up;
  22.     int s,i;
  23.     struct sockaddr fsock;
  24.     char *cp;
  25.  
  26.     if(argc < 2){
  27.         tprintf("S#  Type    PCB      Remote socket         Owner\n");
  28.         for(s=0;s<Nusock;s++){
  29.             up = &Usock[s];
  30.             if(up->type == NOTUSED)
  31.                 continue;
  32.             i = sizeof(fsock);
  33.             if(getpeername(s,(char *)&fsock,&i) == 0 && i != 0) {
  34.                 cp = psocket(&fsock);
  35.                 tprintf("%3d %-8s%-8lx %-22s%-8lx %-10s\n",
  36.                  s,Socktypes[up->type],ptol(up->cb.p),cp,
  37.                  ptol(up->owner),up->owner->name);
  38.             }
  39.         }
  40.         return 0;
  41.     }
  42.     s = atoi(argv[1]);
  43.     if(s < 0 || s >= Nusock){
  44.         tprintf("Number out of range\n");
  45.         return 1;
  46.     }
  47.     up = &Usock[s];
  48.     tprintf("%s %lx\n",Socktypes[up->type],ptol(up->cb.p));
  49.     if(up->cb.p == NULL)
  50.         return 0;
  51.     switch(up->type){
  52.     case TYPE_LOCAL_DGRAM:
  53.         tprintf("Qlen: %u packets\n",socklen(s,0));
  54.         break;
  55.     case TYPE_LOCAL_STREAM:
  56.         tprintf("Qlen: %u bytes\n",socklen(s,0));
  57.         break;
  58.     case TYPE_TCP:
  59.         st_tcp(up->cb.tcb);
  60.         break;
  61.     case TYPE_UDP:
  62.         st_udp(up->cb.udp,0);
  63.         break;
  64. #ifdef    AX25
  65.     case TYPE_AX25I:
  66.         st_ax25(up->cb.ax25);
  67.         break;
  68. #endif
  69. #ifdef    NETROM
  70.     case TYPE_NETROML4:
  71.         donrdump(up->cb.nr4);
  72.         break;
  73. #endif
  74.     }
  75.     return 0;    
  76. }
  77.  
  78.